<p class="Head1"><help:link Id="66501">Creating and Organizing Libraries and Modules</help:link></p>
<p class="Paragraph">The following provides an introduction to working with libraries and modules. You will discover how to create and delete libraries and modules, and how to move <help:productname>%PRODUCTNAME</help:productname> Basic projects between documents, templates or the application.</p>
<p class="TextInTable">Generally, each <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic project should be stored in an individual module.</p>
</span></th></tr></table>
<p class="Paragraph"/>
<p class="Head2">Organizing Libraries</p>
<p class="Head3">Creating a New Library</p>
<ul class="L1">
<li class="">
<p class="P2">If you are not in the IDE, first select the <span class="T1">Macro</span> command in the <span class="T1">Tools</span> menu, and click <span class="T1">Organizer</span> in the dialog that follows.</p>
</li>
<li class="">
<p class="P2">If you are already in the IDE, click the <span class="T1">Modules</span> icon to open the corresponding dialog.</p>
</li>
<li class="">
<p class="P2">Click the <span class="T1">Library</span> tab.</p>
<p class="P3">Use Application/Document and then <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/><span class="T1">Library</span> to select the object you want to attach the library to.</p>
</li>
<li class="">
<p class="P3">Click the button <span class="T1">New</span>, and <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic creates a new library.</p>
</li>
</ul>
<p class="Head3">Renaming a Library</p>
<ul class="L3">
<li class="">
<p class="P4">To change the default name of a library, proceed as follows:</p>
</li>
<li class="">
<p class="P4">Right-click the name of the library.</p>
</li>
<li class="">
<p class="P4">The cursor appears at the end of the name, indicating that you can now edit the name. Press Enter to confirm your changes.</p>
</li>
</ul>
<p class="Head3">Deleting a Library</p>
<ul class="L4">
<li class="">
<p class="P5">Use Application/Document and then <span class="T1">Library</span> to select the object to which the library to be deleted is attached.</p>
<p class="TextInTable">Note: As soon as you delete a module, all contained SUBS and FUNCTIONS are permanently deleted.</p>
</span></th></tr></table>
<ul class="L8">
<li class="">
<p class="P9">Click the <span class="T1">Delete</span> button and confirm the dialog that follows with "Yes".</p>
</li>
</ul>
<p class="Head2">Organizing Projects among Documents or Templates</p>
<p class="Paragraph">Once you have developed a program or program project with <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic, you may wish to move specific parts of a program, or the entire macro project, to other documents or templates.</p>
<p class="TextInTable">Note that a <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic program generally consists of more than one macro - i.e., multiple SUBS. Therefore, if you have developed a program with multiple SUBS and FUNCTIONS that call each other, make sure you copy all necessary elements in order for your program to run in another document or template.</p>
</span></th></tr></table>
<p class="Head3">Moving or copying modules, dialogs or libraries between documents, templates and the application.</p>
<ul class="L9">
<li class="">
<p class="P10">First, open all documents or templates among which you want to move the various objects (modules, libraries, dialogs).</p>
</li>
<li class="">
<p class="P10">Select the <span class="T1">Macro</span> command in the <span class="T1">Tools</span> menu, and click <span class="T1">Organizer</span> in the dialog that follows.</p>
</li>
<li class="">
<p class="P10">To move an object to another document or application, simply click the object and drag it to the desired position. A horizontal line indicates between which objects the moved object will be positioned.</p>
</li>
</ul>
<p class="Paragraph">To copy an object, proceed in the same manner, but keep the <help:switch select="System" xmlns:help="http://openoffice.org/2000/help"><help:case select="MAC">(Option)</help:case><help:default>(Ctrl)</help:default></help:switch> key pressed while you drag the object to its new position.</p>
<p class="Head3">Inserting a Library from another <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname>Program</p>
<p class="Paragraph">Libraries are created in every <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> application. As soon as a library is saved, it exists as a folder with two files script.xlb and dialog.xlb. You can then insert these into your project.</p>
<ul class="L10">
<li class="">
<p class="P11">Select the <span class="T1">Macro</span> command in the <span class="T1">Tools</span> menu, and click <span class="T1">Organizer</span> in the dialog that follows.</p>
</li>
</ul>
<p class="Paragraph">Click <span class="T1">Append</span> and select the data you want to insert.</p>